#ifndef SAND_TABLE_TERRAIN_CONTROL
#define SAND_TABLE_TERRAIN_CONTROL
#include <string>
#include "Global.hpp"
#include "glenv.h"
#include "SandTableController.h"
#include "GestureRecognizer.h"


using namespace std;



class SandTableTerrainControl : public GlControl
{
public:

	SandTableTerrainControl ();

	~SandTableTerrainControl ();

	virtual void handle_keypress( unsigned char key, int x, int y );

	virtual void draw();

	virtual void init_render();

	virtual void handle_special_keypress( int key, int x, int y );

	virtual int handle_timer( int val );

	virtual void handle_reshape( int width, int height );

private:

	SandTableController< 5, 4 > _controller;
	wstring _terrainFile;
	wstring _terrainTexFile;
	BYTE * _terrainData;
	float _lengths[20];
	int _width;
	int _height;
	int _centerLoc[2];
	int _forbidTime;
	int _winWidth;
	int _winHeight;

	void _loadTerrain ();

	void _loadTextures ();

	void _getLength ();

	bool _updateSandTable ();

	void _setToPerspective ();

	void _setToOrtho ();

};



#endif